package cn.edu.nju.freshdelivery.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import cn.edu.nju.freshdelivery.dao.BuyerDAO;
import cn.edu.nju.freshdelivery.model.Buyer;
import cn.edu.nju.freshdelivery.service.BuyerService;

/**
 * @author RJXY
 * 
 */
@Component
public class BuyerServiceImpl implements BuyerService {
	private BuyerDAO buyerDAO;

	public BuyerDAO getBuyerDAO() {
		return buyerDAO;
	}

	@Resource
	public void setBuyerDAO(BuyerDAO buyerDAO) {
		this.buyerDAO = buyerDAO;
	}

	@Override
	public Buyer findByUsername(String username) {
		if (buyerDAO.findByUsername(username).size() > 0)
			return (Buyer) buyerDAO.findByUsername(username).get(0);
		return null;
	}

	@Override
	public void add(Buyer buyer) {
		buyerDAO.save(buyer);
	}

	@Override
	public void modify(Buyer buyer) {
		buyerDAO.update(buyer);
	}

	
	
}
